//package com.runa.monitor.platinterface.platInterface;
//
//import com.runa.monitor.comm.dto.NodeEquModel;
//import com.runa.monitor.comm.dto.RunaEquArchive;
//import com.runa.monitor.platinterface.platService.InterfaceService;
//import com.runa.monitor.platinterface.platService.MeterService;
//import com.runa.protocol.util.DateUtil;
//import com.runa.rccprotocol.dto.equdata.EquData;
//import net.minidev.json.JSONArray;
//import org.junit.Test;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * 针对计量业务提供的服务
// */
//@RestController
//@RequestMapping("feign/meterWork")
//public class MeterPlatInterface {
//
//    private static final Logger logger = LoggerFactory.getLogger(MeterPlatInterface.class);
//
//    @Resource
//    private InterfaceService interfaceService;
//
//    @Resource
//    private MeterService meterService;
//
////    @GetMapping("refreshFmu/{fmuSerial}")
////    public Map<String, Object> refreshFmu(@PathVariable String fmuSerial) {
////        logger.info("计量请求—刷新{} 集中器", fmuSerial);
//////        Map<String, Object> result = newComm HashMap<>(1);
////        String msg = meterService.refreshConcentrator(fmuSerial);
//////        if (msg == null) {
//////            result.put("code", 200);
//////        } else {
//////            result.put("code", 500);
//////            result.put("msg", msg);
//////        }
//////        return result;
////    }
//
//    @GetMapping("allRead/{taskNo}")
//    public void allRead(@PathVariable Integer taskNo, @RequestParam("types") NodeEquModel.NodeEquType... types) {
//        logger.info("计量请求—全读取, 节点设备类型： {}, 任务号：{}", types, taskNo);
//        interfaceService.rccAllReadByTask(taskNo, types);
//    }
//
//    @GetMapping("readFmu/{fmuSerial}/{taskNo}")
//    public String readFmu(@PathVariable String fmuSerial, @PathVariable Integer taskNo) {
//        logger.info("计量请求—网络设备全读  网络设备号：{}, 任务号：{}", fmuSerial, taskNo);
//        return interfaceService.rccReadNetEqu(fmuSerial, taskNo, NodeEquModel.NodeEquType.values());
//    }
//
//    @GetMapping("readFmuNow/{fmuSerial}/{taskNo}")
//    public void readFmuNow(@PathVariable String fmuSerial, @PathVariable Integer taskNo) {
//        logger.info("计量请求—立即抄表 网络设备号：{}, 任务号：{}", fmuSerial, taskNo);
//        interfaceService.readFmuNow(fmuSerial, taskNo);
//    }
//
//    @PostMapping("sentEquArchive/{fmuSerial}/{taskNo}")
//    public void sentEquArchive(@PathVariable String fmuSerial, @PathVariable Integer taskNo, @RequestBody List<RunaEquArchive> archives) {
//        logger.info("计量请求—网络设备下发档案开始  网络设备号：{}, 档案信息：{}, 任务号：{}", fmuSerial, JSONArray.toJSONString(archives), taskNo);
//        interfaceService.rccSentEquArchive(fmuSerial, taskNo, archives);
//    }
//
//    @DeleteMapping("clearEquArchive/{fmuSerial}/{taskNo}")
//    public void clearEquArchive(@PathVariable String fmuSerial, @PathVariable Integer taskNo) {
//        logger.info("计量请求—清除档案  网络设备号：{}, 任务号：{}", fmuSerial, taskNo);
//        interfaceService.rccClearEquArchive(fmuSerial, taskNo);
//    }
//
//    @GetMapping("readEquArchive/{fmuSerial}/{taskNo}")
//    public void readEquArchive(@PathVariable String fmuSerial, @PathVariable Integer taskNo, @RequestParam List<Integer> indexes) {
//        logger.info("计量请求—网络设备读档案  网络设备号：{}, 测点号：{}, 任务号：{}", fmuSerial, indexes, taskNo);
//        interfaceService.readEquArchive(fmuSerial, taskNo, indexes);
//    }
//
//    @GetMapping("readMeter/{fmuSerial}/{taskNo}")
//    public void readMeter(@PathVariable String fmuSerial, @PathVariable Integer taskNo,
//                          @RequestParam("meterSerial") List<String> meterSerial) {
//        logger.info("计量请求—抄表  网络设备号：{}, 表编号：{}, 任务号：{}", fmuSerial, meterSerial, taskNo);
//        interfaceService.rccReadNodeData(fmuSerial, taskNo, meterSerial, EquData.EquDataType.METER);
//    }
//
//    @GetMapping("readValve/{fmuSerial}/{taskNo}")
//    public void readValve(@PathVariable String fmuSerial, @PathVariable Integer taskNo,
//                          @RequestParam("valveSerial") List<String> valveSerial) {
//        logger.info("计量请求—抄阀  网络设备号：{}, 阀编号：{}, 任务号：{}", fmuSerial, valveSerial, taskNo);
//        interfaceService.rccReadNodeData(fmuSerial, taskNo, valveSerial, EquData.EquDataType.VALVE);
//    }
//
//    @GetMapping("readBuildValve/{fmuSerial}/{taskNo}")
//    public void readBuildValve(@PathVariable String fmuSerial, @PathVariable Integer taskNo,
//                               @RequestParam("valveSerial") List<String> valveSerial) {
//        logger.info("计量请求—抄楼站阀  网络设备号：{}, 阀编号：{}, 任务号：{}", fmuSerial, valveSerial, taskNo);
//        interfaceService.rccReadNodeData(fmuSerial, taskNo, valveSerial, EquData.EquDataType.PUBLIC_UNIT);
//    }
//
//    @GetMapping("readPanel/{fmuSerial}/{taskNo}")
//    public void readPanel(@PathVariable String fmuSerial, @PathVariable Integer taskNo,
//                          @RequestParam("panelSerial") List<String> panelSerial) {
//        logger.info("计量请求—抄温度面板  网络设备号：{}, 面板编号：{}, 任务号：{}", fmuSerial, panelSerial, taskNo);
//        interfaceService.rccReadNodeData(fmuSerial, taskNo, panelSerial, EquData.EquDataType.TEMPERATURE_PANEL);
//    }
//
//    @GetMapping("valveOnOffControl/{fmuSerial}/{taskNo}")
//    public void valveOnOffControl(@PathVariable String fmuSerial,
//                                  @PathVariable Integer taskNo,
//                                  @RequestParam("valveSerial") List<String> valveSerial,
//                                  Boolean ifLock, Integer opening) {
//        logger.info("计量请求—户阀通断控制  网络设备编号：{}, 阀编号：{}, 锁定：{}, 开度：{}, 任务号：{}", fmuSerial, valveSerial, ifLock, opening, taskNo);
//        interfaceService.valveOnOffControl(fmuSerial, taskNo, valveSerial, ifLock, opening, true);
//    }
//
//    @GetMapping("valveTemperatureControl/{fmuSerial}/{taskNo}")
//    public void valveTemperatureControl(@PathVariable String fmuSerial,
//                                        @PathVariable Integer taskNo,
//                                        @RequestParam List<String> valveSerial, Float temperature,
//                                        Boolean ifLock, Float temperatureUp, Float temperatureDown) {
//        logger.info("计量请求—户阀温度控制  " +
//                        "网络设备编号：{}, 阀编号：{}, 温度：{}, 锁定：{}, 上限：{}, 下限：{}, 任务号：{}",
//                fmuSerial, valveSerial, temperature, ifLock, temperatureUp, temperatureDown, taskNo);
//        interfaceService.valveTemperatureControl(fmuSerial, taskNo, valveSerial, temperature, ifLock, temperatureUp, temperatureDown, true);
//    }
//
//    @PostMapping("valveTemperatureComp/{fmuSerial}/{taskNo}")
//    public void valveTemperatureComp(@PathVariable String fmuSerial,
//                                     @PathVariable Integer taskNo,
//                                     @RequestParam List<String> valveSerial, Float compensation) {
//        logger.info("计量请求—户阀温度补偿  " +
//                "网络设备编号：{}, 阀编号：{}, 补偿值：{}, 任务号：{}", fmuSerial, valveSerial, compensation, taskNo);
//        interfaceService.valveTemperatureComp(fmuSerial, taskNo, valveSerial, compensation);
//    }
//
//    @PostMapping("buildValveControl/{fmuSerial}/{taskNo}")
//    public void buildValveControl(@PathVariable String fmuSerial,
//                                  @PathVariable Integer taskNo,
//                                  @RequestParam Integer model,
//                                  @RequestParam List<String> valveSerials,
//                                  @RequestBody Map param) {
//        logger.info("计量请求—楼站阀门控制  网络设备编号：{}, 阀门编号：{}, 控制模式：{}, 控制参数：{}, 任务号：{}", fmuSerial, valveSerials, model, param, taskNo);
//        interfaceService.buildValveControl(fmuSerial, taskNo, valveSerials, model, param);
//    }
//
//
//    @GetMapping("buildValveParam/{fmuSerial}/{taskNo}")
//    public void buildValveParam(@PathVariable String fmuSerial,
//                                @PathVariable Integer taskNo,
//                                Integer model, String valveSerial) {
//        logger.info("计量请求—读楼站阀门参数  网络设备编号：{}, 阀门编号：{}, 参数类型：{}, 任务号：{}", fmuSerial, valveSerial, model, taskNo);
//        interfaceService.buildValveParam(fmuSerial, taskNo, valveSerial, model);
//    }
//
//    @PostMapping("buildValveModel/{fmuSerial}/{taskNo}")
//    public void buildValveModel(@PathVariable String fmuSerial,
//                                @PathVariable Integer taskNo,
//                                @RequestParam boolean model,
//                                @RequestParam List<String> valveSerials) {
//        logger.info("计量请求—楼站阀门模式修改 网络设备编号：{}, 阀门编号：{}, 模式：{}, 任务号：{}", fmuSerial, valveSerials, model, taskNo);
//        interfaceService.buildValveModel(fmuSerial, taskNo, valveSerials, model);
//    }
//
//
//
////    @GetMapping("mockRequest/{fmuSerial}")
////    public void mockRequest(@PathVariable("fmuSerial") String fmuSerial,
////                            @RequestParam("struct") String struct) {
////        logger.info("模拟请求---  网络设备编号：{}, struct: {}", fmuSerial, struct);
////        interfaceService.mockRequest(fmuSerial, struct);
////    }
//
//
//
////    @GetMapping("readUnitDevice/{fmuSerial}/{taskNo}")
////    public void readUnitDevice(@PathVariable String fmuSerial,
////                               @PathVariable Integer taskNo,
////                               String meterSerial, String valveSerial) {
////        logger.info("平衡请求—读取单元调控设备  网络设备编号：{}, 楼表编号：{}, 楼阀编号：{}", fmuSerial, meterSerial, valveSerial);
////        interfaceService.readUnitDevice(taskNo, fmuSerial, meterSerial, valveSerial);
////    }
////
////    @GetMapping("ctrlUnitDevice/{fmuSerial}/{taskNo}")
////    public void ctrlUnitDevice(@PathVariable String fmuSerial,
////                               @PathVariable Integer taskNo,
////                               @RequestParam("valveSerial") List<String> valveSerial,String valveOpen) {
////        logger.info("平衡请求—控制单元调控设备  网络设备编号：{}, 阀编号：{}, 开度：{}", fmuSerial, valveSerial, valveOpen);
////        interfaceService.ctrlUnitDevice(taskNo, fmuSerial, valveSerial, valveOpen);
////    }
////
////    @PostMapping("sendForwardData")
////    public Object sendForwardData(@RequestParam List<String> netSerials,
////                                  @RequestParam Integer port,
////                                  @RequestParam Integer ctrl,
////                                  @RequestParam String forwardData) {
////        logger.info("集中器透明转发—[{}], {}", netSerials, forwardData);
////        return interfaceService.fmuForwardData(netSerials, port, ctrl, forwardData);
////    }
////
////    @PostMapping("setTimeCorrect")
////    public Object setTimeCorrect(@RequestParam List<String> netSerials,
////                                 @RequestParam String timeString) {
////        Date date = null;
////        if (!StringUtils.isEmpty(timeString)) {
////            date = DateUtil.toDateGeneric(timeString);
////        }
////        if (date == null) {
////            date = newComm Date();
////        }
////        timeString = DateUtil.toStringGeneric(date);
////        logger.info("集中器校时—[{}], {}", netSerials, timeString);
////        return interfaceService.fmuTimeCorrect(netSerials, date);
////    }
////
////
////    @RequestMapping(value = "ctrlGatewayDevice", method = RequestMethod.POST)
////    public Map<String, Object> downloadFileGateway(@RequestParam String msg,@RequestParam(required = false) boolean retry) {
////        return interfaceService.meterDownloadFile(msg,retry);
////    }
////
////    @PostMapping(value = "issuedPanelParam/{gateway}")
////    public Map<String, Object> issuedPanelParam(@PathVariable String gateway, @RequestBody PanelData panelData) {
////        logger.info("计量请求— 小瑞面板数据下发 网关: {}, 面板编号: {}", gateway, panelData.getSn());
////        return interfaceService.issuedPanelParam(gateway, panelData);
////    }
//}
